<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>商品销售平台统计</title>

<script language="javascript" src="/fuman/js/TableFreeze.js"></script>
<script language="javascript">
function settips(parentid,parentsku,goodsid)
{
	if (confirm("你确认将商品设置为不再提醒？以后不管销售如何都不会显示在这个列表?")) {
	
 	$.post("/datareport/ajaxbutton", {"op": "setgoods_recommend","parentid":parentid,"parentsku":parentsku},
	  function(data){
			window.location.reload();
	  },"json");
	 }
}

$(function() {
	$("#table2").freezeHeader();
})

</script>
<body class="withvernav">
<div class="bodywrapper">
{{include file='/public/leftmenu.tpl'}}
<div class="centercontent tables">
  <div class="pageheader notab">
    <h1 class="pagetitle">商品销售平台推荐</h1>
     <span class="pagedesc">
     国内淘宝和天猫销量不显示在列表
  </span>
 
    
     </div>
  <!--pageheader-->
     <div>
   		<div style="float:left">
         {{if $managers || $classid==8}}
        &nbsp;&nbsp;&nbsp;
        <button class="stdbtn btn_lime" onClick="doRecommend(0);return false;">推荐商品</button>&nbsp;&nbsp;&nbsp;
        {{/if}}
        </div>
         <div class="page">{{$pageList}} 计{{$total}}条记录，共{{$totalpage}}页</div>
   </div>
  <div id="contentwrapper" class="contentwrapper"> 
    <!--搜索栏-->
    <form class="stdform stdform2" method="get" action="/datareport/saleplatform">
      <div class="tableoptions">
       
        统计维度:
        <select name="saletype" id="saletype" class="selection select2_group" style="width:100px;" >
            <option value="0">默认总销量</option>
            <option value="1" {{if $saletype eq 1}} selected{{/if}}>总销售</option>
            <option value="2" {{if $saletype eq 2}} selected{{/if}}>7天销售</option>
            <option value="3" {{if $saletype eq 3}} selected{{/if}}>30天销售</option>
            <option value="4" {{if $saletype eq 4}} selected{{/if}}>60天销售</option>
        </select>
         &nbsp;
        销售数量: <input type="text" name="nums" id="nums" class="width100" value="{{$nums}}" />
        &nbsp;
        关键词: <input type="text" name="other" id="other" class="width100" value="{{$other}}" />
        
         状态:
        <select name="status" id="status" class="selection select2_group" style="width:100px;" >
            <option value="0">请选择</option>
            <option value="1" {{if $status eq 1}} selected{{/if}}>已完成</option>
            <option value="2" {{if $status eq 2}} selected{{/if}}>未完成</option>
        </select>
        <button class="btn btn_orange btn_search radius50">Search</button>
        
        
      </div>
    </form>
    <!--搜索栏结束-->
    <table cellpadding="0"  id="table2" cellspacing="0" border="0" class="stdtable">
      <colgroup>
      <col class="con1" />
      <col class="con0" />
      <col class="con1" />
      <col class="con0" />
      <col class="con1" />
      <col class="con0" />
      <col class="con1" />
      </colgroup>
      <thead>
        <tr>
          <th class="head0">&nbsp;</th>
         
          <th class="head0">商品编号</th>
          <th class="head1">商品名称</th>
          <th class="head0">总销售</th>
          <th class="head1">7天销售</th>
          <th class="head1">30天销售</th>
          <th class="head1">美国 </th>
          <th class="head1">AMZ1</th>
          <th class="head1">AMZ2</th>
          <th class="head1">AMZ3</th>
          <th class="head1">AMZ4</th>
          <th class="head1">AMZ5</th>
          
	        <th class="head1">德国 </th>
	        <th class="head1">日本 </th>
            <th class="head1">备用 </th>
          <th class="head0">Ebay</th>
          <th class="head0">Wish</th>
          <th class="head0">速卖通</th>
          <th class="head0">网站</th>
          <th class="head0">Shopee</th>
	        <th class="head0">状态</th>
           <th class="head0">推荐</th>
          <th class="head0">操作</th>
        </tr>
      </thead>
      <tbody>
      
      {{foreach from=$list item=li key=key}}
      {{if $li.noplatform==0}}
      <tr>
        <td><input name="ppid[]" type="checkbox" class="none" id="ppid[]" value="{{$li.goods_parentID}}" /></td>
        <td><a href="/product/productlist?other={{$li.goods_parent_sku}}" target="_blank">{{$li.goods_parent_sku}}</a></td>
        <td width="10%" valign="middle">{{$li.goods_name}}</td>
        <td>{{$li.allsale}}</td>
         <td class="center" title="7天销量">{{$li.sales1}}</td>
        <td class="center" title="30天销量">{{$li.sales2}}</td>
        	
        <td class="center" title="美国亚马逊">
		      {{foreach from=$li.platform item=res key=skey}}
		      {{if $res.name=='Amazon'}}
		      {{$res.other}}
		      {{else}}

		      {{/if}}
		      {{/foreach}}
	      </td>
        <td class="center" title="美国1组">
          {{foreach from=$li.platform item=res key=skey}}
		      {{if $res.name=='Amazon'}}
		        {{$res.str_amazon1}}
		      {{else}}

		      {{/if}}
		      {{/foreach}}
        </td>
        <td class="center" title="美国2组">
         {{foreach from=$li.platform item=res key=skey}}
		      {{if $res.name=='Amazon'}}
		        {{$res.str_amazon2}}
		      {{else}}

		      {{/if}}
		      {{/foreach}}
        </td>
         <td class="center" title="美国3组">
         {{foreach from=$li.platform item=res key=skey}}
		      {{if $res.name=='Amazon'}}
		        {{$res.str_amazon3}}
		      {{else}}

		      {{/if}}
		      {{/foreach}}
        </td>
         <td class="center" title="美国4组">
         {{foreach from=$li.platform item=res key=skey}}
		      {{if $res.name=='Amazon'}}
		        {{$res.str_amazon4}}
		      {{else}}

		      {{/if}}
		      {{/foreach}}
        </td>
         <td class="center" title="美国5组">
         {{foreach from=$li.platform item=res key=skey}}
		      {{if $res.name=='Amazon'}}
		        {{$res.str_amazon5}}
		      {{else}}

		      {{/if}}
		      {{/foreach}}
        </td>
	      <td class="center" title="德国亚马逊">
		      {{foreach from=$li.platform item=res key=skey}}
		      {{if $res.name=='Amazon'}}
		        {{$res.germany}}
		      {{else}}

		      {{/if}}
		      {{/foreach}}
	      </td>
	      <td class="center" title="日本亚马逊">
		      {{foreach from=$li.platform item=res key=skey}}
		      {{if $res.name=='Amazon'}}
		      {{$res.japan}}
		      {{else}}

		      {{/if}}
		      {{/foreach}}
	      </td>
            <td class="center" title="备用">
		      {{foreach from=$li.platform item=res key=skey}}
		      {{if $res.name=='Amazon'}}
		      {{$res.str_usaa}}
		      {{else}}

		      {{/if}}
		      {{/foreach}}
	      </td>
        <td class="center" title="ebay">
        	{{foreach from=$li.platform item=res key=skey}}
       		 {{if $res.name=='ebay'}}
            	{{$res.goods_number}}
            {{else}}
            
            {{/if}}
             {{/foreach}}
        </td>
        <td class="center"  title="Wish">
        {{foreach from=$li.platform item=res key=skey}}
         	{{if $res.name=='Wish'}}
            	{{$res.goods_number}}
            {{else}}
            
            {{/if}}
             {{/foreach}}
        </td>
        <td class="center" title="aliexpress">
         {{foreach from=$li.platform item=res key=skey}}
       		 {{if $res.name=='aliexpress'}}
            	{{$res.goods_number}}
            {{else}}
            
            {{/if}}
              {{/foreach}}
        </td>
        <td class="center" title="Magento">
        {{foreach from=$li.platform item=res key=skey}}
        	{{if $res.name=='Magento'}}
            	{{$res.goods_number}}
            {{else}}
            
            {{/if}}
        {{/foreach}}
        </td>
         <td class="center" title="Shopee">
         {{foreach from=$li.platform item=res key=skey}}
         	{{if $res.name=='Shopee'}}
            	{{$res.goods_number}}
            {{else}}
            
            {{/if}}
             {{/foreach}}
         </td>

	      <td class="center" width="5%">
		      {{if $li.status ==0}}
		        未完成
		      {{/if}}
		      {{if $li.status ==1}}
		        <span style="color:red;">已完成</span>&nbsp;
				<a href="{{$li.linkUrl}}" target="_blank"><img src="/fuman/images/icons/attachment.png" /> </a>
		      {{/if}}
	      </td>
         <td width="20%">
         	{{foreach from=$li.receivers item=res key=key}}
												{{if $res.flag eq 1}}
													<a href="{{$res.address}}" style="color:red;" target="_blank">{{$arr_receiver[$res.userid]}}&nbsp;</a>
												{{elseif $res.flag eq 2}}
												    <a href="javascript:void(0);">
													<s>{{$arr_receiver[$res.userid]}}</s>
													<span id="tip_info">取消原因：{{$res.address}}</span></a>
												{{else}}
														{{$arr_receiver[$res.userid]}}&nbsp;
												{{/if}}
							{{/foreach}}
         </td>
        <td class="center">
         {{if $managers || $classid==8}}
        	<a href="javascript:void(0)" onClick="settips({{$li.goods_parentID}},'{{$li.goods_parent_sku}}')">不再显示</a>
	        &nbsp;
		        {{if $li.status ==0}}
		            <a href="javascript:void(0)" onClick="doFinish({{$li.goods_parentID}},'{{$li.goods_parent_sku}}')">已完成</a>
	            {{/if}}
	        {{/if}}
      
        </td>
      </tr>
      {{/if}}
        {{/foreach}}
         
        </tbody>
      
    </table>
    <div class="page">{{$pageList}}</div>
    <br />
    <br />
  </div>
</div>
<!--bodywrapper-->

<!-- 模态框（Modal）交运内容 -->
		<form action="/externalBuy/doRecommendGoods" enctype="multipart/form-data" method="post" name="dorecommendattributeform" id="dorecommendattributeform"  >
			<div class="modal" id="dorecommendform" tabindex="-1" role="dialog" aria-labelledby="sexpressform" aria-hidden="true" style="margin-top: 60px;padding-top:60px;">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal"
							        aria-hidden="true" onClick="javascript:$('#dorecommendform').hide();">× </button>
							<h4 class="modal-title"><span id="order_mailno" style="font-size:18px;">推荐商品信息接收者</span></h4>
						</div>
						<div class="modal-body">
							<table width="100%" border="0" cellspacing="0" cellpadding="0">
								<tr>
									<td align="left" width="100">
										{{foreach from=$receiverlist item=li key=key}}
											<input type="checkbox" value="{{$li.id}}" name="receiver[]" />{{$li.name}}&nbsp;&nbsp;
										{{/foreach}}
									</td>
								</tr>
							</table>
							<div class="modal-footer">
								<button type="button" class="btn btn-default"
								        data-dismiss="modal" style="display:none"> 关闭 </button>
								<input type="hidden" name="extIds" id="extIds" value="">
								<button type="button" class="btn btn-primary"  onclick="doRecommend(1)">确认推荐</button>
							</div>
						</div>
						<!-- /.modal-content -->
					</div>
					<!-- /.modal-dialog -->
				</div>
			</div>
		</form>
		<!-- /.modal -->

	<!-- 已完成弹出框-->
	<!-- 模态框（Modal）交运内容 -->
	<form action="/datareport/doFinish" enctype="multipart/form-data" method="post" name="dorecommendattributeform" id="dorecommendattributeform" target="_blank" style="font-size: 14px;font-family: Helvetica, 'Hiragino Sans GB', 'Microsoft Yahei', '微软雅黑', Arial, sans-serif;line-height: 21px;color: #666;">
		<div class="modal" id="dofinishform" tabindex="-1" role="dialog" aria-labelledby="sexpressform" aria-hidden="true" style="margin-top: 60px;padding-top:60px;">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"
						        aria-hidden="true" onClick="javascript:$('#dofinishform').hide();">× </button>
						<h4 class="modal-title"><span id="addsure" style="font-size:18px;">已完成</span></h4>
					</div>
					<div class="modal-body">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td align="left">链接地址：</td>
								<td  align="left">
										<span>
										<input type='text'  name='linkUrl' id='linkUrl' placeholder='请输入相关链接,如：http://www.baidu.com'/>
										</span>
								</td>
							</tr>
						</table>
						<div class="modal-footer">
							<button type="button" class="btn btn-default"
							        data-dismiss="modal" style="display:none"> 关闭 </button>
							<input type="hidden" name="goods_parent_sku" id="goods_parent_sku" value="">
							<button type="button" class="btn btn-primary"  onclick="doFinish(0,0,2)">保存</button>
						</div>
					</div>
					<!-- /.modal-content -->
				</div>
				<!-- /.modal-dialog -->
			</div>
		</div>
	</form>
	<!-- /.modal -->
<script type="text/javascript">
	//推荐商品
	function doRecommend(flag) {
		var str = selectallpro();
		if(str !=false)
		{
			if(flag==0){
				$("#extIds").val(str);
				$('#dorecommendform').show();
			}
			if(flag==1){
				var vote_arr = document.getElementsByName("receiver[]");
				var idarr = new Array();
				var i=0;
				var strs="";
				for(var j = 0; j < vote_arr.length; j++){
					if(vote_arr[j].checked == true){
						idarr[i] = vote_arr[j].value;
						strs += vote_arr[j].value+",";
						i++;
					}
				}
				if(i<=0){
					alert("未选中相关推荐者");
					return false;
				}
				$.post("/datareport/ajaxbutton", {"op": "doRecommendGoods","ids":str,"receiver":strs},
						function(data){
							if(data)
							{
								alert("推荐成功!");
								window.location.reload();
							}
						},"text");


			}

		}
	}
	function doFinish(goods_parentID,goods_parent_sku,flag =1) {
		if(flag == 1){
			$("#goods_parent_sku").val(goods_parent_sku);
			$("#dofinishform").show();
		}
		if(flag==2){
			var goods_parent_sku = $("#goods_parent_sku").val();
			var linkUrl  = $.trim($("#linkUrl").val());
			if(linkUrl){

			}else{
				alert("链接不能为空");return false;
			}
			$.post("/datareport/ajaxbutton", {"op": "doFinish","goods_parent_sku":goods_parent_sku,"linkUrl":linkUrl},
					function(data){
						if(data == 200)
						{
							alert("成功!");
							window.location.reload();
						}
					},"text");
		}
	}
</script>
</body>
</html>